﻿<UserControl x:Class="Kokomo.Environment.Documents.SummaryView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:doc="clr-namespace:Kokomo.Environment.Documents"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<FrameworkElement.Resources>
		<Style TargetType="{x:Type TextBox}">
			<Setter Property="IsReadOnly" Value="True"/>
			<Setter Property="IsReadOnlyCaretVisible" Value="True"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TextBox}">
						<ScrollViewer x:Name="PART_ContentHost"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<BooleanToVisibilityConverter x:Key="boolVisibilityConverter"/>
	</FrameworkElement.Resources>

	<Expander
		IsExpanded="True"
		>
		<Expander.Header>
			<TextBox
				Text="{Binding Heading, Mode=OneWay}"
				FontSize="20"
				FontWeight="DemiBold"
				Foreground="Black"
				/>
		</Expander.Header>
		<!--<Expander.Template>
			<ControlTemplate TargetType="{x:Type Expander}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>

					<StackPanel Orientation="Horizontal">
						<ContentPresenter ContentSource="Header"/>

						<ToggleButton
							IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={x:Static RelativeSource.TemplatedParent}}"
							>
							<ToggleButton.Style>
								<Style TargetType="{x:Type ToggleButton}">
									<Setter Property="Template">
										<Setter.Value>
											<ControlTemplate TargetType="{x:Type ToggleButton}">
												<TextBlock>
													<Hyperlink>
														<Run Text="Expand &gt;&gt;"/>
													</Hyperlink>
												</TextBlock>
											</ControlTemplate>
										</Setter.Value>
									</Setter>

									<Style.Triggers>
										<Trigger Property="IsChecked" Value="True">
											<Setter Property="Template">
												<Setter.Value>
													<ControlTemplate TargetType="{x:Type ToggleButton}">
														<TextBlock>
															//<Hyperlink>
																<Run Text="&lt;&lt; Collapse"/>
															//</Hyperlink>
														</TextBlock>
													</ControlTemplate>
												</Setter.Value>
											</Setter>
										</Trigger>
									</Style.Triggers>
								</Style>
							</ToggleButton.Style>
						</ToggleButton>
					</StackPanel>

					<ContentPresenter
						Grid.Row="1"
						Visibility="{TemplateBinding IsExpanded, Converter={StaticResource boolVisibilityConverter}}"
						/>
				</Grid>
			</ControlTemplate>
		</Expander.Template>-->

		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
			</Grid.RowDefinitions>

			<ItemsControl
				ItemsSource="{Binding Commands}"
				/>

			<ItemsControl
				Grid.Row="1"
				Grid.IsSharedSizeScope="True"
				ItemsSource="{Binding Details}"
				Margin="6"
				>
				<ItemsControl.Resources>
					<DataTemplate DataType="{x:Type doc:SummaryDetailItem}">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition SharedSizeGroup="Heading" Width="Auto"/>
								<ColumnDefinition Width="6"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>

							<TextBlock Text="{Binding Heading, StringFormat={}{0}:}" FontWeight="Bold"/>

							<TextBox Grid.Column="2" Text="{Binding Text, Mode=OneWay}"/>
						</Grid>
					</DataTemplate>

					<DataTemplate DataType="{x:Type doc:SummaryDetailLinkItem}">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition SharedSizeGroup="Heading" Width="Auto"/>
								<ColumnDefinition Width="6"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>

							<TextBlock Text="{Binding Heading, StringFormat={}{0}:}" FontWeight="Bold"/>

							<TextBlock Grid.Column="2">
								<Hyperlink Command="{Binding Command}" CommandParameter="{Binding CommandParameter}">
									<Run Text="{Binding Text, Mode=OneWay}" />
								</Hyperlink>
							</TextBlock>
						</Grid>
					</DataTemplate>
				</ItemsControl.Resources>
			</ItemsControl>
		</Grid>
	</Expander>
</UserControl>
